﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;
using System;

public class PianoInfo
{
    public string testid;
    public string testname;
    public string testscore;
}
public class Jsonreader : MonoBehaviour {/*读取json存入text*/
    public List<PianoInfo> pianolist = new List<PianoInfo>();
    private void Awake()
    {
        parseJson();
        disJson(pianolist);
    }
    public void parseJson()
    {
        UnityEngine.TextAsset s = Resources.Load("lily") as TextAsset;
        string tmp = s.text;
        Debug.Log(tmp);
        pianolist = JsonMapper.ToObject<List<PianoInfo>>(tmp);
        /*var textobj = Resources.Load("lily") as object;
        string json = JsonMapper.ToJson(textobj);
        JsonData jd = JsonMapper.ToObject(json);
        Debug.Log(jd["lily"]);*/
    }
    void disJson(List<PianoInfo>  pianoList)
    {
        foreach(PianoInfo info in pianolist)
        {
            Debug.Log("id:" + info.testid + "   " + "name:" + info.testname + "   " + "score:" + info.testscore);
        }
    }
    
}
